﻿using System.Collections.Generic;
using HgAdapter;

namespace HgAdapter
{
	public class ProjectCommitInfo
	{
		private Dictionary<string, VersionStatus> commitInfo;

		private string projectPath = string.Empty;


		public string ProjectPath
		{
			get { return projectPath; }
		}

		private ProjectCommitInfo()
		{}

		private readonly static ProjectCommitInfo instance = new ProjectCommitInfo();
		public  static ProjectCommitInfo Instance
		{
			get
			{
				return instance;
			}
		}

		public void Init(string path)
		{
			projectPath = path;
			Reload();
		}

		public void Reload()
		{
			if (projectPath.Length > 0)
				commitInfo = (new HgStatus()).Run();
		}

		public VersionStatus GetVersionStatus(string fileName)
		{
			VersionStatus versionStatus;
			if (commitInfo.TryGetValue(fileName, out versionStatus))
				return versionStatus;
			else
				return VersionStatus.Empty;
		}
	}
}
